<template>
  <div v-show="!loading">
    <div class="start-page" :class="{'modal-active':showReview}">
      <div class="top-nav">
        <ul class="btn-group">
          <li v-for="(item,index) of photoCategory">
            <button
              :style="{color:topNavColor[index]}"
            >
              {{ item.name }}
            </button>
          </li>
        </ul>


        <div class="startpage-search-frame">
          <input type="search" name="q" id="search-text" placeholder="Search...">
        </div>
      </div>
      <div class="images-wrap">
      <span class="sm-thumb" v-for="item of imageList" @click="showReviewPop(item)">
        <img v-lazy="item.src" :key="item.src" alt="" :title="item.src">
      </span>
      </div>





    </div>

    <!-- review -->
    <transition name="bounce">
      <div v-show="showReview" class="image-view-wrap" @click="showReview = false">
        <div class="image-view"></div>
        <div style="display:inline-block;height:100%;vertical-align:middle;"></div>
        <transition name="bounce">
          <div
            v-if="showReview"
            style="display: inline-block; vertical-align: middle; position: relative; z-index: 1; cursor: pointer; min-width: 150px; min-height: 150px; width: auto; height: auto;">
            <img :src="imgView" alt="">
          </div>
        </transition>
      </div>
    </transition>

          <!-- 固定在下方 -->

      <header id="photo-header">
        <h1><a style="cursor: pointer;"><strong>相册 - ZIPBLOG.</strong> </a></h1>
        <nav>
          <ul>
            <li>
              <router-link to="/" class="" style="cursor: pointer;">返回主页</router-link>
            </li>
            <li>
              <router-link to="/about" class="icon solid fa-info-circle" style="cursor: pointer;">关于</router-link>
            </li>
          </ul>
        </nav>
      </header>

  </div>
</template>

<script>
  import {getPhotoList} from "@/api/home";
  import {mapState} from "vuex";
  //https://unpkg.com/animate.css@3.5.2/animate.min.css
  export default {
    name: "photos",
    data() {
      return {
        photoCategory: [
          {name: "最新", id: ""},
          {name: "热门", id: ""},
          {name: "上传", id: ""},
          {name: "随机", id: ""},
          {name: "论坛", id: ""},
        ],
        topNavColor: ['#ad3', '#b760f0', '#e73', '#d55', '#fb3'],
        imageList: [],
        showReview: false,
        imgView: ""
      }
    },
    computed: {
      ...mapState({
        loading: state => state.showLoading
      })
    },
    methods: {
      getPhotoList() {
        this.$store.commit("setLoading",true)
        getPhotoList().then(({data}) => {

          this.imageList = data.data.map((item) => {
            return {
              src: item
            }
          })
          this.$store.commit("setLoading",false)
        })
      },
      showReviewPop(img) {
        this.imgView = img.src
        this.showReview = true
      }
    },
    mounted() {
      this.getPhotoList()
      document.body.style.background = `#242629`
    },
    beforeDestroy() {
      document.body.removeAttribute('style')
    }
  }
</script>

<style lang="scss" scoped>
  .image-view {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    opacity: 0;
    filter: alpha(opacity=0);

  }

  .image-view-wrap {
    position: fixed;
    left: 0px;
    top: 0px;
    z-index: 20000;
    width: 100%;
    height: 100%;
    text-align: center;
    cursor: pointer;
    opacity: 1;
  }

  .icon {
    text-decoration: none;
    border-bottom: none;
    position: relative;
  }

  .icon:before {
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-smoothing: antialiased;
    display: inline-block;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    line-height: 1;
    text-transform: none !important;
    font-family: 'Font Awesome 5 Free';
    font-weight: 400;
  }

  .icon > .label {
    display: none;
  }

  .icon:before {
    line-height: inherit;
  }

  .icon.solid:before {
    font-weight: 900;
  }

  .icon.brands:before {
    font-family: 'Font Awesome 5 Brands';
  }

  #photo-header {
    -moz-transform: translateY(0);
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
    -moz-transition: -moz-transform 1s ease;
    -webkit-transition: -webkit-transform 1s ease;
    -ms-transition: -ms-transform 1s ease;
    transition: transform 1s ease;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-select: none;
    background: #1f2224;
    bottom: -1em;
    height: 5em;
    left: 0;
    line-height: 4em;
    padding: 0 1.5em;
    position: fixed;
    user-select: none;
    width: 100%;
    z-index: 10002;
    text-align: left;
  }

  @media screen and (max-width: 736px) {


    #photo-header {
      transform: translateY(0);
      bottom: auto;
      height: 4em;
      padding: 0 1em;
      top: 0;
    }

    .start-page{
      margin-top: 4em;
    }
  }

  #photo-header h1 {
    color: #a0a0a1;
    display: inline-block;
    font-size: 1em;
    line-height: 1;
    margin: 0;
    vertical-align: middle;
  }

  #photo-header h1 a {
    border: 0;
    color: inherit;
  }

  #photo-header h1 a:hover {
    color: inherit !important;
  }


  #photo-header nav {
    position: absolute;
    right: 0;
    top: 0;
  }

  #photo-header nav > ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  #photo-header nav > ul > li {
    display: inline-block;
    padding: 0;
  }

  #photo-header nav > ul > li a {
    -moz-transition: background-color 0.5s ease;
    -webkit-transition: background-color 0.5s ease;
    -ms-transition: background-color 0.5s ease;
    transition: background-color 0.5s ease;
    border: 0;
    color: #ffffff;
    display: inline-block;
    letter-spacing: 0.1em;
    padding: 0 1.65em;
    text-transform: uppercase;
  }

  #photo-header nav > ul > li a.icon:before {
    color: #505051;
    float: right;
    margin-left: 0.75em;
  }

  #photo-header nav > ul > li a:hover {
    color: #ffffff !important;
  }

  #photo-header nav > ul > li a.active {
    /*background-color: #242629;*/
  }


  strong, b {
    color: #ffffff;
    font-weight: 300;
  }


  //http://www.h-ui.net/Hui-1-cssReset.shtml
  .start-page {

    &.modal-active {
      filter: blur(8px);


      &::after {
        background: rgba(36, 38, 41, 0.5);
        transition: opacity 0.5s ease, visibility 0.5s;
        content: '';
        display: block;
        height: 100%;
        left: 0;
        position: absolute;
        top: 0;
        width: 100%;
        pointer-events: auto;
        opacity: 1;
        visibility: visible;
        z-index: 10003;
      }
    }

    border-top-width: 0;
    padding: 30px 19px 80px;
    text-align: center;
    background: #242629;

    .top-nav {
      text-align: center;

      .btn-group{
        padding:0;
        margin:0;
        li{display: inline-block;padding: 5px;}
      }

      button {
        width: 100px;
        background: linear-gradient(to top, rgba(0, 0, 0, .5) 0, rgba(0, 0, 0, .1) 100%);
        border-radius: 3px;
        padding: 20px;
        /*margin-left: 10px;*/
        cursor: pointer;
        font-size: 16px;

        &:hover {
          background: rgba(0, 0, 0, .1);
          box-shadow: 0 0 3px rgb(0 0 0 / 50%) inset;
        }
      }

      .startpage-search-frame {
        width: 50%;
        margin: 30px auto 0;
        background: rgba(255, 255, 255, .1);
        transition-property: background-color, box-shadow;
        transition-duration: .3s;
        border-radius: 2px;
        padding: 0 .5em;
        box-shadow: 2px 2px 4px rgb(0 0 0 / 60%);

        input {
          padding: 0;
          height: 46px;
          line-height: 46px;
          background: 0 0;
          box-shadow: none;
          color: #fff;
          text-shadow: 1px 1px 0 rgb(0 0 0 / 50%);
          width: 100%;
          font-size: 20px;
        }
      }
    }
  }


  .images-wrap {

    max-width: 1560px;
    margin: 26px auto 0;
    /*display: flex;*/
    /*align-items: center;*/
    text-align: left;

    span.sm-thumb {
      width: 20%;
      padding: 4px 6px;
      display: inline-block;
    }

    img {
      width: 100%;
      height: 100%;
      border-radius: 5px;
      box-shadow: 2px 2px 5px rgb(0 0 0 / 50%);
      height: 200px;
      cursor: pointer;

      &:hover {
        filter: brightness(130%);
        box-shadow: 2px 2px 8px rgb(0 0 0 / 80%);
      }
    }
  }

  @media screen and (max-width: 1680px) {
    .images-wrap {
      span.sm-thumb {
        width: 33%;
      }
    }
  }

  @media screen and (max-width: 1280px) {
    .images-wrap {
      span.sm-thumb {
        width: 50%;
      }
    }
  }

  @media screen and (max-width: 980px) {
    .images-wrap {
      span.sm-thumb {
        width: 100%;
      }
    }
    .start-page .top-nav .startpage-search-frame {
      width: 60%;
    }
    .start-page .top-nav button {
      width: 100px;

    }
  }

  @media screen and (max-width: 480px) {
    .start-page .top-nav button {
      width: 55px;
      padding: 10px;
      /*margin-bottom: 5px;*/
    }
    .start-page .top-nav .startpage-search-frame {
      width: 80%;
    }
  }


  .bounce-enter-active {
    animation: bounceIn .5s;
  }

  .bounce-leave-active {
    animation: bounceIn .5s reverse;
  }

  @keyframes bounceIn {
    0% {
      transform: scale(0);
    }
    50% {
      transform: scale(1.5);
    }
    100% {
      transform: scale(1);
    }
  }


  /*@keyframes bounceIn {*/

  /*  0% {*/
  /*    opacity: 0;*/
  /*    -webkit-transform: scale3d(.3, .3, .3);*/
  /*    transform: scale3d(.3, .3, .3)*/
  /*  }*/

  /*  20% {*/
  /*    -webkit-transform: scale3d(1.1, 1.1, 1.1);*/
  /*    transform: scale3d(1.1, 1.1, 1.1)*/
  /*  }*/

  /*  40% {*/
  /*    -webkit-transform: scale3d(.9, .9, .9);*/
  /*    transform: scale3d(.9, .9, .9)*/
  /*  }*/

  /*  60% {*/
  /*    opacity: 1;*/
  /*    -webkit-transform: scale3d(1.03, 1.03, 1.03);*/
  /*    transform: scale3d(1.03, 1.03, 1.03)*/
  /*  }*/

  /*  100% {*/
  /*    -webkit-transform: scale3d(.97, .97, .97);*/
  /*    transform: scale3d(.97, .97, .97)*/
  /*  }*/

  /*}*/

</style>

<style>

</style>
